package com.thor.palmmall.rest.order.converter;

import java.util.ArrayList;
import java.util.List;

import org.springframework.core.convert.converter.Converter;

import com.thor.palmmall.rest.order.ASection;
import com.thor.palmmall.spi.order.SSection;

public class ASectionConverter implements Converter<List<SSection>, List<ASection>> {
  public static ASectionConverter getInstance() {
    if (instance == null)
      instance = new ASectionConverter();
    return instance;
  }

  private static ASectionConverter instance;

  @Override
  public List<ASection> convert(List<SSection> sourceList) {
    if (sourceList == null || sourceList.size() == 0) {
      return null;
    }
    List<ASection> list = new ArrayList<ASection>();
    for (SSection source : sourceList) {
      ASection target = new ASection();

      target.setAmount(source.getAmount());
      target.setDiscount(source.getDiscount());

      list.add(target);
    }
    return list;
  }
}
